//xlang Source, Name:RCPServer.xcsm 
//Date: Sat Oct 11:25:44 2018 

class RCPServer{

	static const int CAUNSI_TCP = 1;
    
    static const String TAG = "RCP";
    //远程调用通道
	public RemoteCallPipe<IServer, IClient> rcs = new RemoteCallPipe<IServer, IClient>();	
        
    public bool create(IServer server, IRCPEventHandler rcph, Unsi unsi, int port){
		
        //创建远程调用通道
		if (rcs.create(unsi.getAsyncDirectOutput(), rcph, server, true)){
			rcs.enableBuffer(true);
			//开启设置网络参数 最大超时5秒
			if (unsi.create(rcs.getAsyncDirectInput(), CAUNSI_TCP, port, 0)){
				
				//开启网络服务
				if (unsi.start()){
					//开启远程调用通道
					return 0 == rcs.startForServer();
				}
			}else{
				Log.e(TAG, "create unsi failed");
            }
        }else{
			Log.e(TAG, "create rcp failed");
		}
        
        return false;
    }
};
